package com.zzjr.tools.java.ssm.table;

import javax.swing.*;
import javax.swing.border.Border;
import javax.swing.border.EmptyBorder;
import javax.swing.table.TableCellRenderer;
import java.awt.*;

/**
 * Description:
 * 
 * @Date Create on 2015年10月12日
 * @author <a href="mailto:Aromarich@zuozh.com">Aromarich</a>
 * @since version1.0 Copyright 2015 ZZJR All Rights Reserved.
 */
public class CWCheckBoxRenderer extends JCheckBox implements TableCellRenderer {
	
	// ~ Static fields/initializers
	// -------------------------------------------------------------------------------------
	
	private static final long serialVersionUID = 1L;
	
	// ~ Instance fields
	// ------------------------------------------------------------------------------------------------
	
	Border border = new EmptyBorder(1, 2, 1, 2);
	
	// ~ Constructors
	// ---------------------------------------------------------------------------------------------------
	
	public CWCheckBoxRenderer() {
		super();
		setOpaque(true);
		setHorizontalAlignment(SwingConstants.CENTER);
	}
	
	// ~ Methods
	// --------------------------------------------------------------------------------------------------------
	
	@Override
	public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus,
			int row, int column) {
		if (value instanceof Boolean) {
			setSelected(((Boolean) value).booleanValue());
			
			// setEnabled(table.isCellEditable(row, column));
			setForeground(table.getForeground());
			setBackground(table.getBackground());
			
		}
		
		return this;
	}
} // end class CWCheckBoxRenderer
